<?php
/**
 * 广告相关
 */
namespace Cps\Controller;
use Common\Controller\CommonController;
class AdController extends CommonController{

    /**
     * 广告统计
     * @param $appid
     * @param $uid
     * @param $location
     * @param $clickId
     */
    public function count()
    {
        $appid      = I('post.appid','','htmlspecialchars');            //载体id（小程序）
        $uid        = I('post.uid','','htmlspecialchars');              //用户ID
        $location   = I('post.location','','htmlspecialchars');         //广告位置
        $clickId    = I('post.clickId','','htmlspecialchars');          //广告源ID

        if (!$appid)
        {
            $this->returnData('','非法操作');
        }

        $data = array(
            'appid'=>$appid,
            'uid'=>$uid,
            'create_time'=>date('Y-m-d H:i:s',time()),
            'clicknum'=>'1',
            'location'=>$location,
            'clickid'=>$clickId,
            'time'=>time(),
        );

        M('cps_ad_cnzz')->data($data)->add();
        $this->returnData();
    }
}